/*
 * Copyright (c) 2010-2013 Ruben Chakhmakhchyan. All rights reserved.
 * 
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Eclipse Public License
 * Version 1.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://opensource.org/licenses/EPL-1.0 and read it before using this file.
 */

#include <stdio.h>
#include <string.h>

#include "pdf_obj.h"


void PdfImage::load( char* filename )
{
    FILE *pFile = NULL;
    errno_t result = ::fopen_s( &pFile, filename, "rb");

    m_data = new byte_t[ 10000000 ];
    ::memset( m_data, 0, 10000000 );

    byte_t* bp = m_data; // buffer pointer

    size_t read = 0;
    size_t count = 0;

    while( ( count = ::fread( bp, 1, 1024, pFile ) ) > 0 )
    {
        bp += count;
    }
    ::fclose( pFile );
    pFile = NULL;

    m_size = bp - m_data;
}

void PdfPage::drawImage( PdfImage* image )
{
    m_image = image;
}

void PdfPages::addPages( uint_t count )
{
    for ( uint_t i = 0; i < count; i++ )
    {
        PdfPage* page = new PdfPage();
        m_pages.push_back( page );
    }

    m_count += count;
}
